<template>

<div id="warning">
  <el-row>
    <mu-appbar title="警戒值" style="background-color:#409EFF">
      <mu-icon-button  icon="arrow_back_ios" slot="left" :to="{name: 'GmMenu' }"/>
    </mu-appbar>
  </el-row>

  <el-row>
    <el-col :span="12">
    </el-col>
    <el-col :span="12">
      <i class="el-icon-arrow-down" style="float:right" @click="handleTools"></i>
    </el-col>
  </el-row>
  <div class= "tools" v-show="tools">
    <el-row>
      <el-col :xs="6" :sm="4" :md="3" :lg="3">
        玩家账号
      </el-col>
      <el-col :xs="18" :sm="20" :md="21" :lg="21">
        <el-input v-model="condition.uid" size="mini" @blur="handleFind"></el-input>
      </el-col>
    </el-row>

    <el-row>
      <el-button-group>
        <el-button type="primary" @click="handleOrder(0)">按净输排</el-button>
        <el-button type="primary" @click="handleOrder(1)">按净赢排</el-button>
      </el-button-group>
    </el-row>

  </div>


  <el-table
    :data="tableData"
    style="width: 100%">
    <el-table-column
      prop="uid"
      label="玩家ID">
    </el-table-column>
    <el-table-column
      prop="binderUid"
      label="上级ID">
    </el-table-column>
    <!-- <el-table-column
      prop="organizer"
      label="顶级ID">
    </el-table-column> -->
    <el-table-column
      prop="nickName"
      label="昵称">
    </el-table-column>
    <el-table-column
      prop="wNdot"
      label="总输金币">
      <template slot-scope="scope">
        <span>{{scope.row.lNdot}}个</span>
      </template>
    </el-table-column>
    <el-table-column
      prop="lNdot"
      label="总赢金币">
      <template slot-scope="scope">
        <span>{{scope.row.wNdot}}个</span>
      </template>
    </el-table-column>
    <el-table-column
      prop="wlNdot"
      label="净赢金币">
    </el-table-column>
    <el-table-column
      prop="createTime"
      label="注册时间">
    </el-table-column>
  </el-table>

  <el-row>
    <center>
      <el-pagination
        small
        layout="prev, pager, next"
        :total="condition.total"
        :page-size="condition.pageSize"
        :current-page="condition.currentPage"
        @current-change="handleCurrentChange">
      </el-pagination>
    </center>
  </el-row>
</div>

</template>

<style>
#warning  .el-row {
  margin-bottom: 16px;
}
#warning  .el-col {
  margin-bottom: 8px;
}
</style>

<script>
  import moment from 'moment'
  export default {
    data () {
      return {
        tools: true,
        tableData: [],
        condition: {
          orderby: 0, // 0 默认按总输排， 1 按总赢排 净输赢
          uid: '',
          currentPage: 1,
          pageSize: 10,
          total: 0,
          account: sessionStorage.getItem('account')
        }
      }
    },
    methods: {
      handleTools () {
        if (this.tools) {
          this.tools = false
        } else {
          this.tools = true
        }
      },
      handleFind () {
        if (this.condition.uid === '' || this.condition.uid.length === 0) {
          this.condition.uid = -1
        }
        let that = this
        this.$axios({
          method: 'get',
          url: '/api/CarrieroperatorService.warning',
          params: this.condition
        })
        .then(function (resp) {
          that.condition.uid = ''
          if (resp.data.status === 'success') {
            for (let item in resp.data.data) {
              resp.data.data[item].createTime = moment.utc(resp.data.data[item].createTime).zone(-8).format('YYYY-MM-DD HH:mm:ss')
            }
            that.tableData = resp.data.data
            that.condition.total = resp.data.page.total
          } else {
            that.$message({
              showClose: true,
              message: resp.data.cause,
              type: 'warning'
            })
          }
        })
      },
      handleCurrentChange (val) {
        this.condition.currentPage = val
        this.handleFind()
      },
      handleOrder (type) {
        if (type === 0) {
          this.condition.orderby = 0
          this.init()
        }
        if (type === 1) {
          this.condition.orderby = 1
          this.init()
        }
      },
      init () {
        this.handleFind()
      }
    },
    mounted () {
      this.init()
    }
  }
</script>
